/**
 * 二维数组，根据输入依次往里放字母，并检查是否有"HNIST"出现
 */
#include <bits/stdc++.h>
using namespace std;

#include <bits/extc++.h>

using Real = long double;
using llt = long long;
using pii = pair<int, int>;
using vi = vector<int>;

llt const MOD = 998244353LL;

int N, M, K;
vector<string> Board;

bool check(int x, int y, char ch){
    switch(ch){
        case 'H':{
            return Board[x].substr(y, 5) == "HNIST";
        }break;
        case 'N':{
            return y >= 2 and Board[x].substr(y - 1, 5) == "HNIST";
        }break;
        case 'I':{
            return y >= 3 and Board[x].substr(y - 2, 5) == "HNIST";
        }break;
        case 'S':{
            return y >= 4 and Board[x].substr(y - 3, 5) == "HNIST";
        }break;
        case 'T':{
            return y >= 5 and Board[x].substr(y - 4, 5) == "HNIST";
        }break;
        default: return false;
    }
    assert(0);
}

void proc(){
    char ch;
    for(int x,y,i=1;i<=K;++i){
        cin >> x >> y >> ch;
        Board[x][y] = ch;
        if(check(x, y, ch)) return (void)(cout << i << endl);
    }
    cout << "Oh no!\n";
}

int main(){
#ifndef ONLINE_JUDGE
    freopen("z.txt", "r", stdin);
#endif
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int nofakse = 1;
    // cin >> nofakse;
    while(nofakse--){
        cin >> N >> M >> K;
        Board.assign(N + 1, string(M + 1, '\0'));
        proc();
    }
    return 0;
}